package indi.kane.demandlist.service.impl;

import indi.kane.demandlist.dao.UserMapper;
import indi.kane.demandlist.entity.User;
import indi.kane.demandlist.service.IUserService;
import indi.kane.demandlist.vo.ResultVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName: UserService
 * @Author: kane
 * @Date: 2020-05-25 11:58 上午
 * @Description:
 */
@Service
public class UserService implements IUserService

{
    @Resource
    private UserMapper userMapper;
    @Override
    public ResultVo selectByPrimaryKey(int id) {
        User result = userMapper.selectByPrimaryKey(id);
        return ResultVo.success(result);
    }

    @Override
    public ResultVo login(String name, String password) {
        User result = userMapper.login(name, password);
        if(result == null){
            return ResultVo.failed(ResultVo.SUCCESS_CODE_WRONG,null,"用户名或密码错误.");
        }
        return ResultVo.success(result);
    }
}